package com.atguigu.gmall.product.service.impl;

import com.atguigu.gmall.model.item.to.SkuDetailTO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.gmall.model.product.entity.SkuImage;
import com.atguigu.gmall.product.service.SkuImageService;
import com.atguigu.gmall.product.mapper.SkuImageMapper;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author lyd
* @description 针对表【sku_image(库存单元图片表)】的数据库操作Service实现
* @createDate 2025-03-10 20:57:08
*/
@Service
public class SkuImageServiceImpl extends ServiceImpl<SkuImageMapper, SkuImage>
    implements SkuImageService{

    @Override
    public List<SkuDetailTO.SkuImageVo> getSkuImageVoList(Long skuId) {
        List<SkuImage> skuImages = this.lambdaQuery()
                .eq(SkuImage::getSkuId, skuId)
                .list();
        List<SkuDetailTO.SkuImageVo> skuImageVos = skuImages.stream()
                .map(item -> {
                    SkuDetailTO.SkuImageVo skuImageVo = new SkuDetailTO.SkuImageVo();
                    skuImageVo.setImgUrl(item.getImgUrl());
                    return skuImageVo;
                }).collect(Collectors.toList());
        return skuImageVos;
    }
}




